[REFACTOR][RUNTIME] Phase out tvm::runtime::regex_match#19620
Merged
Conversation
tvm::runtime::regex_match was a thin C++ wrapper that bounced through a
global ffi::Function back into Python's re.match — introduced solely to
avoid pulling <regex> into TVM (libstdc++ dual-ABI conflict with pre-cxx11
pytorch wheels). The only C++ caller is the DNNL JSON runtime, where
every pattern reduces to substring containment.
- Remove src/runtime/regex.{h,cc} and the python tvm.runtime.regex_match
global registration.
- Inline std::string::find checks at the DNNL JSON runtime call sites.
- Drop the dead regex.h include from the relax update_param_struct_info
pass.
Contributor
There was a problem hiding this comment.
Code Review
This pull request removes the tvm.runtime.regex_match utility and its associated C++ and Python implementations, replacing regex-based operations in the DNNL JSON runtime with simpler, more efficient string matching helpers (contains and contains_any). The review feedback suggests improving the flexibility of the contains_any helper by implementing it as a C++17 variadic template with a fold expression, which would also allow simplifying the call sites in the subgraph engine construction.
Replace the fixed three-argument contains_any helper with a C++17 variadic template + fold expression. With the more general form, fold the back-to-back deconv1d/2d/3d and conv*_transpose checks into a single call (branch-order intact — the merged check still precedes the plain conv check).
spectrometerHBH
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tvm::runtime::regex_matchwas a thin C++ wrapper that bounced through aglobal
ffi::Functionback into Python'sre.match. It was introducedsolely to avoid pulling
<regex>into TVM (libstdc++ dual-ABI conflict withpre-cxx11 pytorch wheels). The only C++ caller is the DNNL JSON runtime, where
every pattern reduces to substring containment —
re.matchanchors at thestart only, so
.*X.*is equivalent tos.find(X) != npos.src/runtime/regex.{h,cc}and the Pythontvm.runtime.regex_matchglobal registration.
contains/contains_anyhelpers indnnl_json_runtime.ccand inline
std::string::findat the 15 call sites.regex.hinclude fromsrc/relax/transform/update_param_struct_info.cc.No CMakeLists.txt change needed —
src/runtime/*.ccis picked up by glob.USE_DNNLis OFF in the ci_gpu container, so DNNL-specific runtime testsare not exercised locally. The DNNL translation unit compiles cleanly with
the inlined helpers, and the full TVM build (636 targets) passes.